package com.bdqn.ch02.repositroy;

import com.bdqn.ch02.entity.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;


public interface UserRepositroy extends JpaRepository<User,Long>,JpaSpecificationExecutor<User> {
    public List<User> findByUsrNameOrUsrPasswordLike(String usrName, String usrPassword);

    //@Query(value = "select u from User u where u.usrRoleId=?1")
    //public List<User> findByUsrRoleId(Long roleId);

    @Query("select u from User u")
    public Page<User> findUserPage(Pageable pageable);


    Page<User> findAll(Pageable pageable);

//    @Query("select u.usrId as usrId,u.usrName as usrName,u.usrPassword as usrPassword,u.usrRoleId as usrRoleId," +
//            "u.usrFlag as usrFlag,r.roleName as roleName from User u,Role r where u.usrRoleId=r.roleId and u.usrId=?1")
//    public UserInfo getUserInfo(Long usrId);
}
